public class 数组最大 {
    public static void main(String[] args) {
        int[] x = {1,2,3,4,5};
        Arr_max(x);
        Arr_max(x);
    }
    public static int[] Arr_max(int[] arr){
        int max=0;
        int index=0;
        for (int i = 0; i < arr.length; i++) {
            if(max<arr[i]){
                max=arr[i];
            }
        }
        for (int i = 0; i < arr.length; i++) {
            if(max == arr[i]){
                index=i;
            }
        }
        System.out.println("最大值为:"+max+","+"索引为:"+index);
        return arr;
    }
    public static int[] Arr_min(int[] arr){
        int min=0;
        int index=0;
        for (int i = 0; i < arr.length; i++) {
            if(min>arr[i]){
                min=arr[i];
            }
        }
        for (int i = 0; i < arr.length; i++) {
            if(min == arr[i]){
                index=i;
            }
        }
        System.out.println("最大值为:"+min+","+"索引为:"+index);
        return arr;
    }
}
